<?php
function writeName()
{
    echo "Kai Jim Refsnes";
}
 
echo "My name is ";
writeName();
echo "\n";

function writeName2($fname)
{
    echo $fname . " Refsnes.<br>";
}
 
echo "My name is ";
writeName2("Kai Jim");
echo "My sister's name is ";
writeName2("Hege");
echo "My brother's name is ";
writeName2("Stale");

echo "\n";
function add($x,$y)
{
    $total=$x+$y;
    return $total;
}
 
echo "1 + 16 = " . add(1,16);

echo "\n";

function foo(){
        echo "in foo\n";
}
function bar(){ 
        echo "in bar\n";
}
$foo_func = "foo";
$foo_func(); // calls foo()

echo "\n";

class Foo{
        function foo_func()
        {
                $name='bar';
                $this->$name(); // calls $this->bar()
        }
        function bar()
        {
                echo "in Foo::bar\n";
        }
}
$foo = new Foo();
$foo_funcname = "foo_func";
$foo->$foo_funcname(); // calls $foo->foo_func()


?>